<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        拜访记录列表
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }

        /* layui-table 表格内容允许换行 */
        .layui-table-cell {
            height: auto;
        }

    </style>
</head>

<body>

<div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>销售业务</cite></a>
            <a><cite>拜访记录</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center">
        <div class="layui-form-pane" style="margin-top: 5px;">
            <div class="layui-form-item" style="padding-left: 3%">
                <label class="layui-form-label">客户名称</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="customerName" placeholder="客户名称">
                </div>

                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="projectName" placeholder="请输入项目名称">
                </div>

                <label class="layui-form-label">项目阶段</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="belongStage" placeholder="项目阶段名称">
                </div>
                <label class="layui-form-label">联系人员</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="linkmanName" placeholder="请输入联系人员姓名">
                </div>
                <hr>

                <label class="layui-form-label">拜访日期</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  class="layui-input" placeholder="开始时间" name="createTimeStart" id="createTimeStart">
                </div>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  class="layui-input" placeholder="截止时间" name="createTimeEnd" id="createTimeEnd">
                </div>

                <label class="layui-form-label">下次回访</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  class="layui-input" placeholder="开始时间" name="nextTimeStart" id="nextTimeStart">
                </div>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  class="layui-input" placeholder="截止时间" name="nextTimeEnd" id="nextTimeEnd">
                </div>
                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索
                    </button>
                    <button type="reset" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe666;</i>重置
                    </button>
                </div>

            </div>
        </div>
    </form>


    <div class="layui-card-body">
        <table class="layui-table" id="test" lay-filter="test">
        </table>
    </div>
</div>
</body>

<script type="text/html" id="barDemo">
    <a title="详情" lay-event="view" class="ml-5 layui-btn-xs layui-btn layui-btn-normal">详情</a>
</script>


<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script type="text/javascript" src="../../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../../js/vue.min.js"></script>
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>


<script>

    layui.use(['table', 'laydate', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var table = layui.table;
        var form = layui.form;
        okLoading.close($);

        //执行一个laydate实例
        laydate.render({
            trigger: 'click',
            type: 'date',
            elem: '#nextTimeStart' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            trigger: 'click',
            type: 'date',
            elem: '#nextTimeEnd' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            trigger: 'click',
            type: 'datetime',
            elem: '#createTimeStart' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            trigger: 'click',
            type: 'datetime',
            elem: '#createTimeEnd' //指定元素
        });
        //方法级渲染
        var t1 = table.render({
            elem: '#test',
            url: $baseUrl + 'xa/projectLog/findListByPage',
            where: {
                userId: $userId,
                logType: 2,
                businessTypeId: 0
            },
            headers: {
                token: $token
            }
            , toolbar: '#toolbarDemo',

            // toolbar: true,
            cols: [
                [
                    {
                        title: '序号',
                        type: 'numbers',
                        width: '5%',
                        fixed: 'left',
                        align: 'center',
                    },
                    {
                        field: 'create_time',
                        title: '拜访日期',
                        align: 'center',
                        // width: '8%',
                        // templet(item) {
                        //     if (item.contractNature === 1) {
                        //         return '<button type="button" class="layui-btn layui-btn-xs layui-btn layui-btn-xs layui-btn-radius layui-btn">收款</button>';
                        //     } else if (item.contractNature === 2) {
                        //         return '<button type="button" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-warm">付款</button>';
                        //     }else {
                        //         return '<button type="button" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger">未知</button>';
                        //     }

                        // }
                    },
                    {
                        field: 'customerName',
                        title: '客户名称',
                        align: 'center',
                        // templet(item) {
                        //     if (item.contractType === 1) {
                        //         return '<span>销售合同</span>';
                        //     } else {
                        //         return '<span>工程合同</span>';
                        //     }

                        // }
                    },
                    {
                        field: 'project_name',
                        title: ' 项目名称',
                        align: 'center',
                        // templet(item) {
                        //     return '<span style="font-weight:bold">'+item.projectName+'</span><br><span>'+item.customerName+'</span>';

                        // }
                    },
                    {
                        field: 'belong_stage',
                        title: '所属阶段',
                        align: 'center'
                    },
                    {
                        // field: 'contractHappenAmount',
                        title: '联系人员',
                        align: 'center',
                        templet(item) {
                            if (item.linkman_position === '') {
                                return item.linkman_name + '-' + item.linkman_tel;
                            } else {
                                return '[' + item.linkman_position + ']-' + item.linkman_name + '-' + item.linkman_tel;
                            }

                        }
                    },
                    {
                        field: 'next_time',
                        title: '下次拜访日期',
                        align: 'center'
                    },
                    {
                        field: 'operation_content',
                        title: '沟通内容',
                        align: 'center',
                        width: '25%',
                    },
                    // {
                    //     // field: 'status',
                    //     title: '操作',
                    //     templet: '#barDemo',
                    //     width: '6%',
                    //     fixed: 'right',
                    //     align: 'center',
                    //
                    // }
                    ]
            ],
            request: {
                pageName: 'pageNum', //页码的参数名称，默认：page
                limitName: 'pageSize',
            },
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 0 //规定成功的状态码，默认：0
                ,
                msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,
                countName: 'total' //规定数据总数的字段名称，默认：count
                ,
                dataName: 'data', //规定数据列表的字段名称，默认：data
            },
            id: 'test',
            page: true,
            height: 'auto',
            even: true,
            done: function (res, curr, count) {
                //是否有权限或权限是否失效
                // authorizeState();
                // this.statisticsFun();
                //解决操作栏因为内容过多换行问题
                $(".layui-table-main tr").each(function (index, val) {
                    $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
                    $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
                });

            }
        });

        form.on('submit(sreach)', function (data) {
            var customerName = data.field.customerName;
            var projectName = data.field.projectName;
            var belongStage = data.field.belongStage;
            var linkmanName = data.field.linkmanName;

            var createTimeStart = data.field.createTimeStart;
            var createTimeEnd = data.field.createTimeEnd;
            var nextTimeStart = data.field.nextTimeStart;
            var nextTimeEnd = data.field.nextTimeEnd;

            table.reload('test', {
                where: { //设定异步数据接口的额外参数，任意设
                    customerName: customerName,
                    projectName: projectName,
                    belongStage: belongStage,
                    linkmanName: linkmanName,
                    createTimeStart: createTimeStart,
                    createTimeEnd: createTimeEnd,
                    nextTimeStart: nextTimeStart,
                    nextTimeEnd: nextTimeEnd
                },
            });
            return false;
        })

        //监听工具条
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            let data = obj.data; //获得当前行数据
            let layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            if (layEvent === 'view') { //详情
                admin_add('拜访日志详情', 'visit_records_detail.html?contractId=' + data.log_id)
            }
        });

    });

    function reload(value) {
        table.reload('test', {
            where: {
                name: $("input[name=name]").val(),
                taxpayerIdentificationNumber: $("input[name=taxpayerIdentificationNumber]").val(),
                addressAndTelephoneNumber: $("input[name=addressAndTelephoneNumber]").val(),
                billType: $("select[name=billType]").val(),
                start: $("input[name=start]").val(),
                end: $("input[name=end]").val(),
            }
        });
    }

    function admin_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }
</script>

<script>

    var vm = new Vue({
        el: "#app",
        data: {
            statistics: {
                kaiAmountOfThisMonth: null,
                shouAmountOfThisMonth: null,
            }
        },
        mounted() {
            this.statisticsFun();
        },
        methods: {
            statisticsFun() {
                let request = {
                    url: 'billFlow/findDataStatistical',
                    data: {
                        userId: $userId,
                    },
                    method: "POST",
                };
                sendRequest(request, (res) => {
                    this.statistics = res.data
                });
            }
        }

    });


    // setTimeout(() => {
    //     //修改状态
    //     let form = layui.form;
    //     //查发票类型
    //     let request = {
    //         url: 'dictionary/findDataDictionaryValue',
    //         data: {
    //             userId: $userId,
    //             label: 'INVOICE_TYPE'
    //         },
    //         method: "POST",
    //     };
    //     sendRequest(request, (res) => {
    //         console.log(res);
    //         let billType = res.data;
    //         $.each(billType, function (index, item) {
    //             let opt = $("<option value=" + item + ">" + item + "</option>");
    //             $("select[name=billType]").append(opt);
    //             console.log(opt)

    //         });


    //         form.render('select');
    //     });
    // }, 300)
</script>

</html>
